﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FrienDev.BusinessRules;
using FrienDev.Data;

public partial class Controls_Activity_Info : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.Request["activityid"] != null)
        {
            qqPanel.Visible = true;
            msnPanel.Visible = true;
            int activityID = Convert.ToInt32(Request.QueryString["activityid"]);
            Activity activity = ActivityRules.Instance.GetActivityInfo(activityID);
            if(activity == null)
                return;
            lblActivityAddress.Text = activity.Address;
            lblActivityArea.Text = activity.City.Province.ProvinceName + " - " + activity.City.CityName;
            lblActivityDeadLine.Text = activity.JoinDeadLine.ToString();
            lblActivityEmail.Text = activity.Email;
            lblActivityEndDate.Text = activity.EndDateTime.ToString();
            lblActivityFee.Text = activity.Expense;
            lblActivityMemberNumber.Text = ActivityRules.Instance.GetJoinedUserNum(activityID) + " / " + activity.SignUpLimit;
            lblActivityMSN.Text = activity.MSN;
            lblActivityName.Text = activity.ActivityName;
            hl_ActivityOrganizer.Text = ActivityRules.Instance.GetActivityOrganizer(activityID);
            hl_ActivityOrganizer.NavigateUrl = ApiHelper.Instance.GetUserHomepageLink(ActivityRules.Instance.GetActivityOrganizerId(activityID));
            lblActivityPhone.Text = activity.Phone;
            lblActivityQQ.Text = (activity.QQ.ToString() == "0") ? "" : activity.QQ.ToString();
            lblActivityStartDate.Text = activity.BeginDateTime.ToString();
            lblActivitySubject.Text = activity.Subject;
            hl_ClubName.Text = activity.Club.ClubName.ToString();
            hl_ClubName.NavigateUrl = "~/Club/detail.aspx?clubid=" + activity.ClubId.ToString();
            string activityType = "";
            switch(activity.ActivityType)
            {
                case 0:
                    activityType = "技术交流会";
                    break;
                case 1:
                    activityType = "新产品发布会";
                    break;
                case 2:
                    activityType = "技术培训";
                    break;
                case 3:
                    activityType = "俱乐部聚餐";
                    break;
                case 4:
                    activityType = "体育活动";
                    break;
                case 5:
                    activityType = "其他活动";
                    break;
            }
            lblActivityType.Text = activityType;
            lblTargetAudience.Text = activity.TargetAudience;
            if (lblActivityQQ.Text == "")
            {
                qqPanel.Visible = false;
            }
            if (lblActivityMSN.Text == "")
            {
                msnPanel.Visible = false;
            }

        }
    }
}
